package hxy.cupb.controller;
import	java.awt.Desktop.Action;

import hxy.cupb.entity.UserEntity;
import hxy.cupb.entity.dto.UserEntityDTO;
import hxy.cupb.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//@RestController("/user")
@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {

    @Autowired
    UserService userService;




    @GetMapping("/get/{name}")
    // 有RestController就表明这个返回的就是json数据，而不是页面了
//    @ResponseBody
    public UserEntityDTO getUserEntityDTO(@PathVariable(name = "name") String name){
        log.info("{}",name);
        userService.loadUserByUserName(name);
        return new UserEntityDTO(name,12);
    }
    @GetMapping("/getn")
    // 有RestController就表明这个返回的就是json数据，而不是页面了
//    @ResponseBody
    public UserEntity loadUserByUserName(@RequestParam(name = "name") String name){
        log.info("{}",name);

        return userService.loadUserByUserName(name);
    }
}
